package mulMan.domain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Observable;


public class ListOfPlaylists extends Observable implements List<Playlist>{
	
	private List<Playlist> list;
	
	public ListOfPlaylists() {
		list = new ArrayList<Playlist>();
	}
	
	
	
	public Playlist remove(int index) {
		Playlist result = list.remove(index);
		
		try {
			result.deletePlaylist();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		setChanged();
		notifyObservers(result);

		return result;
	}

	public boolean add(Playlist e) {
		boolean result = list.add(e);
		
		setChanged();
		notifyObservers();
		
		return result;
	}

	public void add(int index, Playlist element) {
		list.add(index, element);
		
		setChanged();
		notifyObservers();
	}

	public boolean addAll(Collection<? extends Playlist> c) {
		boolean result = list.addAll(c);
		
		setChanged();
		notifyObservers();
		
		return result;
	}

	public boolean addAll(int index, Collection<? extends Playlist> c) {
		boolean result = list.addAll(index, c);
		
		setChanged();
		notifyObservers();
		
		return result;
	}

	public void clear() {
		list.clear();
	}

	public boolean contains(Object o) {
		return list.contains(o);
	}

	public boolean containsAll(Collection<?> c) {
		return list.containsAll(c);
	}

	public Playlist get(int index) {
		return list.get(index);
	}

	public int indexOf(Object o) {
		return list.indexOf(o);
	}

	public boolean isEmpty() {
		return list.isEmpty();
	}

	public Iterator<Playlist> iterator() {
		return list.iterator();
	}

	public int lastIndexOf(Object o) {
		return list.lastIndexOf(o);
	}

	public ListIterator<Playlist> listIterator() {
		return list.listIterator();
	}

	public ListIterator<Playlist> listIterator(int index) {
		return list.listIterator(index);
	}

	public boolean remove(Object o) {
		boolean result = list.remove(o);

		try {
			((Playlist) o).deletePlaylist();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		setChanged();
		notifyObservers(o);
		
		return result;
	}

	public boolean removeAll(Collection<?> c) {
		boolean result = list.removeAll(c);
		
		for (Object o : c) {
			try {
				((Playlist) o).deletePlaylist();
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			setChanged();
			notifyObservers(o);
		}
		
		return result;
	}

	public boolean retainAll(Collection<?> c) {
		return list.retainAll(c);
	}

	public Playlist set(int index, Playlist element) {
		return list.set(index, element);
	}

	public int size() {
		return list.size();
	}

	public List<Playlist> subList(int fromIndex, int toIndex) {
		return list.subList(fromIndex, toIndex);
	}

	public Object[] toArray() {
		return list.toArray();
	}

	public <T> T[] toArray(T[] a) {
		return list.toArray(a);
	}

}
